package separateDigits;

import java.util.*;

public class Solution {
    public int[] separateDigits(int[] nums) {
        List<Integer> ans = new ArrayList<>();
        Stack<Integer> stack = new Stack<>();
        for (int num : nums) {
            while (num>0) {
                stack.add(num%10);
                num/=10;
            }
            while (!stack.isEmpty()) {
                ans.add(stack.pop());
            }
        }
        int[] arr = new int[ans.size()];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = ans.get(i);
        }
        return arr;
    }
}
